<?php

namespace App\Console\Commands;

use App\Services\Api\Api;
use Cache;
use Illuminate\Console\Command;

class SysProduct extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sys:product';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $i = 0;
        if (!$this->confirm('资产合作中的找资金模块，领域筛选条件来自于字典，只需要环保和建筑，你配了吗？')) {
            $data = Cache::get('domain_filter_info');
            var_dump($data);
            $i++;
        }
        if (!$this->confirm('解决方案和供应链的领域ID配置好了吗？在front.php配置文件中.[y|n]')) {
            $apiCode = 'CMS#50101';
            $data = [];
            $obj = new Api();
            $postData = $obj->getJavaPostData($apiCode, $data);
            $result = $obj->getJavaResponseData($postData);
            $this->line('以下为系统配置的领域信息:');
            $this->info(var_dump(($result['conditions']['domain'])));
            $i++;
        }
        if (!$this->confirm('政策，行业研究，技术文章的类别，在front.php配置文件中配置好了吗?[y|n]')) {
            $apiCode = 'R#30002';
            $data = [];
            $obj = new Api();
            $postData = $obj->getJavaPostData($apiCode, $data);
            $result = $obj->getJavaResponseData($postData);
            $this->info(var_dump(($result)));
            $i++;
        }

        if ($i > 0) {
            $this->error('你还有  ' . $i . '项  没有配置好，不能上线');
        } else {
            $this->info('可以上线');
        }
    }
}
